// 引入服务器地址
import { Connect } from '@api/apiUrl.js'

let socket = () => {
    let userId = localStorage.getItem('userId')
    var sock = new SockJS(`${Connect.baseURL}webSocketServer/?token=${sock}`)
    this.stomp = Stomp.over(this.sock)
    let _this = this
    this.stomp.connect(
        {},
        function(frame) {
            //连接成功后订阅消息接口
            //订阅个人消息
            _this.stomp.subscribe('/user/queue/chat', function(
                response,
            ) {
                var result = JSON.parse(response.body)
                let hisobj = {}
                hisobj.userId = 1
                hisobj.content = result.msg
                hisobj.ctime = result.createTime
                _this.nwes.push(hisobj)
                // console.log(result)
            })
            //消息发送结果
            _this.stomp.subscribe('/user/queue/msg/result', function(
                response,
            ) {})
        },
    )
}